示例#1
0
    def setUpTestData(cls):
        cls.user = User.objects.create(username='******')

        builder = DemoHistoricalDataBuilder(cls.user)
        builder.create_sleep_fixtures()

        super().setUpTestData()
示例#2
0
    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
示例#3
0
    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()
示例#4
0
    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()
示例#5
0
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()
示例#6
0
    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()
示例#7
0
    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()
示例#8
0
    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)
示例#9
0
 def test_builder(self):
     builder = DemoHistoricalDataBuilder(self.user)
     builder.create_historical_fixtures()