diff --git a/.circleci/config.yml b/.circleci/config.yml index 0f0298a..d5b346c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,37 +1,118 @@ -version: 2 +version: 2.1 + +test-names: &test-names + - mocha:unit:ci + - mocha:unit:rateplan + - test:billing-service-integration + +orbs: + slack: circleci/slack@4.12 + +parameters: + service_name: + default: "my-awesome-service" + type: string + + dev_channels: + default: "slack-notify-test" + type: string + + staging_channels: + default: "slack-notify-test" + type: string + + prodcopy_channels: + default: "slack-notify-test" + type: string + + prod_channels: + default: "slack-notify-test" + type: string + + environment: + default: "prod" + type: string + jobs: - build: - working_directory: ~/circleci-demo-python-django + deploy: docker: - - image: circleci/python:3.6.4 - environment: - PIPENV_VENV_IN_PROJECT: true - DATABASE_URL: postgresql://root@localhost/circle_test?sslmode=disable - - image: circleci/postgres:9.6.2 - environment: - POSTGRES_USER: root - POSTGRES_DB: circle_test + - image: 'cimg/base:stable' + resource_class: hippo/k8s-small + parameters: + test-name: + type: string steps: - - checkout - - run: sudo chown -R circleci:circleci /usr/local/bin - - run: sudo chown -R circleci:circleci /usr/local/lib/python3.6/site-packages - - restore_cache: - key: deps10-{{ .Branch }}-{{ checksum "Pipfile.lock" }} - run: + name: "Simple echo" command: | - sudo pip install pipenv - pipenv install - - save_cache: - key: deps10-{{ .Branch }}-{{ checksum "Pipfile.lock" }} - paths: - - '.venv' - - '/usr/local/bin' - - '/usr/local/lib/python3.6/site-packages' - - run: + pwd + echo "Testing Slack notification." + echo "Test name: << parameters.test-name >>" + - slack/notify: + step_name: "Send Slack - Failure" + channel: "slack-notify-test, " + event: fail + template: basic_fail_1 + - slack/notify: + step_name: "Send Slack - Success" + channel: "slack-notify-test, " + custom: | + { + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": ":white_check_mark: Success to deploy << parameters.test-name >> to << pipeline.parameters.environment >>", + "emoji": true + } + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "text": "View Deployment Job", + "type": "plain_text" + }, + "url": "${CIRCLE_BUILD_URL}" + } + ] + } + ] + } + event: pass + test: + docker: + - image: 'cimg/base:stable' + steps: + - run: command: | - pipenv run python manage.py test - - store_test_results: - path: test-results - - store_artifacts: - path: test-results - destination: tr1 + echo "test my app" + echo "export ENV_NAME=staging" >> $BASH_ENV + +workflows: + test-and-deploy: + jobs: + - test + - slack/on-hold: + channel: 'slack-notify-test' + context: slack-secrets + requires: + - test + - pause_workflow: + requires: + - test + - slack/on-hold + type: approval + - deploy: + matrix: + alias: "Test name" + parameters: + test-name: *test-names + context: slack-secrets + requires: + - pause_workflow + + diff --git a/catalog/tests/test_forms.py b/catalog/tests/test_forms.py index 52cf8ac..446b9e0 100644 --- a/catalog/tests/test_forms.py +++ b/catalog/tests/test_forms.py @@ -31,6 +31,7 @@ def test_renew_form_date_today(self): Test form is valid if renewal_date is today """ date = datetime.date.today() + # date = "hello" form_data = {'renewal_date': date} form = RenewBookForm(data=form_data) self.assertTrue(form.is_valid()) @@ -58,4 +59,4 @@ def test_renew_form_date_field_help_text(self): Test renewal_date help_text is as expected. """ form = RenewBookForm() - self.assertEqual(form.fields['renewal_date'].help_text,'Enter a date between now and 4 weeks (default 3).') \ No newline at end of file + self.assertEqual(form.fields['renewal_date'].help_text,'Enter a date between now and 4 weeks (default 3).') diff --git a/hello.py b/hello.py new file mode 100644 index 0000000..b8d9b2f --- /dev/null +++ b/hello.py @@ -0,0 +1,15 @@ +import requests + +payload = {'term': 'honeydew'} + +res = requests.get('https://itunes.apple.com/search', + params=payload) + +melon_songs = res.json() + +num_results = melon_songs['resultCount'] + +for i in range(num_results): + trackName = melon_songs['results'][i].get('trackName') + artistName = melon_songs['results'][i].get('artistName') + print({trackName}) \ No newline at end of file