def setUpTestData(cls): cls.user = User.objects.create(username='******') builder = DemoHistoricalDataBuilder(cls.user) builder.create_sleep_fixtures() super().setUpTestData()
def setUpAnalyticsData(cls): cls.default_user, _ = User.objects.get_or_create(username='******') builder = DemoHistoricalDataBuilder(cls.default_user) builder.create_historical_fixtures() supplement = Supplement.objects.filter(user=cls.default_user).first() cls.supplement = supplement
def setUpTestData(cls): cls.url = reverse('api-user-export-all-data') cls.user = User.objects.create(username='******') builder = DemoHistoricalDataBuilder(cls.user) builder.create_historical_fixtures() super().setUpTestData()
def setUpTestData(cls): cls.default_user, _ = User.objects.get_or_create(username='******') builder = DemoHistoricalDataBuilder(cls.default_user) builder.create_historical_fixtures() supplement = Supplement.objects.filter(user=cls.default_user).first() supplement_uuid = str(supplement.uuid) cls.supplement = supplement cls.url = reverse('aggregate-supplement-log', args=[supplement_uuid]) super().setUpTestData()
def create_demo_fixtures(): fake = Faker() name = fake.name() # have username be demo-username, so demos-users are easy to tell username = '******'.format(name=name) username = slugify(username) # since these are demo accounts, just set the username/pass the same # so this is a really weird bug since you'd wonder why this would be a get_or_create # but faker doesn't always generate fake names in celery instances ... user, _ = User.objects.get_or_create(username=username) # create a log of this person as a demo user, otherwise we would never be able to tell if someone is a demo or not! _, created = DemoUserLog.objects.get_or_create(user=user) if not created: return fixtures_builder = DemoHistoricalDataBuilder(user, periods_back=180) fixtures_builder.create_historical_fixtures()
def setUpTestData(cls): cls.default_user, _ = User.objects.get_or_create(username='******') builder = DemoHistoricalDataBuilder(cls.default_user) builder.create_historical_fixtures() builder.create_supplement_reminders() super().setUpTestData()
def setUpTestData(cls): cls.user_1, _ = User.objects.get_or_create(username='******') builder = DemoHistoricalDataBuilder(cls.user_1) builder.create_historical_fixtures() builder.create_supplement_reminders(limit=4) cls.url = reverse(SupplementReminder.RESOURCE_NAME) super().setUpTestData()
def test_calculate_productivity_impact(self): details = { 'quantity_range': (0, 5), 'net_productivity_impact_per_quantity': 30, 'peak_threshold_quantity': 3, 'post_threshold_impact_on_productivity_per_quantity': -30, 'sleep_impact_per_quantity': -10, } result = DemoHistoricalDataBuilder.calculate_productivity_impact( 5, details) # if the quantity is 5 ... the result should be # 30 + 30 + 30 + (-30) (-30) = 30 self.assertEqual(result, 30) # test the peak result = DemoHistoricalDataBuilder.calculate_productivity_impact( 3, details) self.assertEqual(result, 90) # test sample size of 1 result = DemoHistoricalDataBuilder.calculate_productivity_impact( 1, details) self.assertEqual(result, 30)
def test_builder(self): builder = DemoHistoricalDataBuilder(self.user) builder.create_historical_fixtures()