from django.test import TestCase from qa_dashboard.settings_test import BASE_DIR from qa_analytics.models import Build, FeatureBuild, ScenarioBuild, StepBuild from ..ingestion import Ingestion class TestIngestion(TestCase): """ A cucumber.json file containing a single passing scenario. """ def test_single_feature_json(self): raw_cucumber_json = open(BASE_DIR + "/jenkins_ingestion/tests/fixtures/one_feature_raw.json").read() Ingestion().run(raw_cucumber_json.encode("utf-8")) # normally this can be done by comparing two files containing a dump of the database, but json.dumps is # unordered and we are storing json as a string in the database. instead, just check the counts and look # at the db manually. self.assertEqual(Build.objects.all().count(), 1) self.assertEqual(FeatureBuild.objects.all().count(), 1) self.assertEqual(ScenarioBuild.objects.all().count(), 1) self.assertEqual(StepBuild.objects.all().count(), 4)