def setUp(self): super(TestRenderToCSVResponse, self).setUp() self.app = TestApp(test_app) Node.remove() time_now = get_previous_midnight() NodeFactory(category='project', date_created=time_now) NodeFactory(category='project', date_created=time_now - timedelta(days=1)) last_time = time_now - timedelta(days=2) NodeFactory(category='project', date_created=last_time) NodeFactory(category='project', date_created=last_time) initial_time = last_time + timedelta(seconds=1) get_days_statistics(initial_time) midtime = last_time + timedelta(days=1, seconds=1) self.time = time_now + timedelta(seconds=1) self.initial_static = [ 'id,users,delta_users,unregistered_users,projects,delta_projects,public_projects,' 'delta_public_projects,registered_projects,delta_registered_projects,date\r', construct_query(1, initial_time), ''] self.latest_static = [ 'id,users,delta_users,unregistered_users,projects,delta_projects,public_projects,' 'delta_public_projects,registered_projects,delta_registered_projects,date\r', construct_query(3, self.time), construct_query(2, midtime), construct_query(1, initial_time), '']
def test_delta(self): get_days_statistics(datetime.utcnow()) ProjectFactory() ProjectFactory() latest = OSFWebsiteStatistics.objects.latest('date') get_days_statistics(datetime.utcnow(), latest) even_later = OSFWebsiteStatistics.objects.latest('date') nt.assert_equal(even_later.delta_projects, 2)
def test_delta(self): get_days_statistics(datetime.utcnow()) NodeFactory(category='project') # makes 2 nodes NodeFactory(category='project') # makes 2 more nodes latest = OSFWebsiteStatistics.objects.latest('date') get_days_statistics(datetime.utcnow(), latest) even_later = OSFWebsiteStatistics.objects.latest('date') nt.assert_equal(even_later.delta_projects, 4)
def test_delta(self): get_days_statistics(datetime.utcnow()) NodeFactory(category="project") # makes 2 nodes NodeFactory(category="project") # makes 2 more nodes latest = OSFWebsiteStatistics.objects.latest("date") get_days_statistics(datetime.utcnow(), latest) even_later = OSFWebsiteStatistics.objects.latest("date") nt.assert_equal(even_later.delta_projects, 4)
def setUp(self): super(TestMetricsGetOSFStatistics, self).setUp() Node.remove() time_now = get_previous_midnight() NodeFactory(category="project", date_created=time_now) NodeFactory(category="project", date_created=time_now - timedelta(days=1)) last_time = time_now - timedelta(days=2) NodeFactory(category="project", date_created=last_time) NodeFactory(category="project", date_created=last_time) get_days_statistics(last_time + timedelta(seconds=1)) self.time = time_now + timedelta(seconds=1)
def setUp(self): super(TestMetricsGetOSFStatistics, self).setUp() Node.remove() time_now = get_previous_midnight() NodeFactory(category='project', date_created=time_now) NodeFactory(category='project', date_created=time_now - timedelta(days=1)) last_time = time_now - timedelta(days=2) NodeFactory(category='project', date_created=last_time) NodeFactory(category='project', date_created=last_time) get_days_statistics(last_time + timedelta(seconds=1)) self.time = time_now + timedelta(seconds=1)
def test_time_now(self): get_days_statistics(datetime.utcnow()) nt.assert_equal(OSFWebsiteStatistics.objects.count(), 1) nt.assert_equal(OSFWebsiteStatistics.objects.latest('date').projects, 2)