def test_organization_builder_update_organization(self): count = Organization.objects.count() organization_json = { "login": "******", "id": 4, "url": "https://api.github.com/orgs/github", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" } organization = organization_builder(organization_json) self.assertEqual(Organization.objects.count(), count + 1) count = Organization.objects.count() organization_json = { "login": "******", "id": 1, "url": "https://api.github.com/orgs/github2", "avatar_url": "https://github.com/images/error/octocat_happy2.gif", "description": "A great organization2" } organization = organization_builder(organization_json) self.assertEqual(Organization.objects.count(), count) self.assertEqual(organization.github_id, organization_json.get('id')) self.assertEqual(organization.name, organization_json.get('login')) self.assertEqual(organization.description, organization_json.get('description')) self.assertEqual(organization.html_url, organization_json.get('url')) self.assertEqual(organization.avatar_url, organization_json.get('avatar_url'))
def test_project_builder_new_project(self): developer = developer_builder({ 'id': 1, 'avatar_url': '', 'login': '******', 'name': 'teste', 'email': 'teste', }) organization = organization_builder({ "login": "******", "id": 1, "url": "https://api.github.com/orgs/github", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }) count = Milestone.objects.count() with open('webhooks/tests/data/project.json') as json_file: project_json = json.load(json_file) project = project_builder(project_json, organization) with open('webhooks/tests/data/milestone.json') as json_file: milestone_json = json.load(json_file) project = project_builder(project_json, organization) milestone = milestone_builder(milestone_json, project, developer) self.assertEqual(Milestone.objects.count(), count + 1) self.assertEqual(milestone.github_id, milestone_json.get('id')) self.assertEqual(milestone.number, milestone_json.get('number')) self.assertEqual(milestone.state, milestone_json.get('state')) self.assertEqual(milestone.title, milestone_json.get('title')) self.assertEqual(milestone.description, milestone_json.get('description')) self.assertEqual(milestone.html_url, milestone_json.get('html_url')) self.assertEqual(milestone.created_at, milestone_json.get('created_at')) self.assertEqual(milestone.closed_at, milestone_json.get('closed_at')) self.assertEqual(milestone.updated_at, milestone_json.get('updated_at')) self.assertEqual(milestone.due_on, milestone_json.get('due_on'))
# coding: utf-8 import json from django.test import TestCase from journal.models import Project from webhooks.builders import project_builder, organization_builder organization = organization_builder({ "login": "******", "id": 1, "url": "https://api.github.com/orgs/github", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }) class ProjectBuilderTestCase(TestCase): def test_project_builder_new_project(self): count = Project.objects.count() with open('webhooks/tests/data/project.json') as json_file: project_json = json.load(json_file) project = project_builder(project_json, organization) self.assertEqual(Project.objects.count(), count + 1) self.assertEqual(project.github_id, project_json.get('id')) self.assertEqual(project.name, project_json.get('name')) self.assertEqual(project.description, project_json.get('description')) self.assertEqual(project.html_url, project_json.get('url')) self.assertEqual(project.created_at, project_json.get('created_at'))
# coding: utf-8 import json from django.test import TestCase from journal.models import Project from webhooks.builders import project_builder, organization_builder organization = organization_builder({ "login": "******", "id": 1, "url": "https://api.github.com/orgs/github", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }) class ProjectBuilderTestCase(TestCase): def test_project_builder_new_project(self): count = Project.objects.count() with open('webhooks/tests/data/project.json') as json_file: project_json = json.load(json_file) project = project_builder(project_json, organization) self.assertEqual(Project.objects.count(), count + 1) self.assertEqual(project.github_id, project_json.get('id')) self.assertEqual(project.name, project_json.get('name')) self.assertEqual(project.description, project_json.get('description')) self.assertEqual(project.html_url, project_json.get('url'))