How to use registered_projects method in dbt-osmosis

Best Python code snippet using dbt-osmosis_python

test_node_summary.py

Source:test_node_summary.py Github

copy

Full Screen

1import datetime2from django.utils import timezone3from osf.models import AbstractNode4from tests.base import OsfTestCase5from osf_tests.factories import UserFactory, RegistrationFactory, ProjectFactory, WithdrawnRegistrationFactory6from nose.tools import * # PEP8 asserts7from scripts.analytics.node_summary import NodeSummary8class TestNodeCount(OsfTestCase):9 def setUp(self):10 super(TestNodeCount, self).setUp()11 self.user = UserFactory()12 # 3 Projects - Public, Private, Private Component13 self.public_project = ProjectFactory(is_public=True)14 self.private_project = ProjectFactory(is_public=False)15 self.private_component = ProjectFactory(parent=self.private_project)16 # 5 Registrations - Public, Public Registrations of Private Proj + Component, Embargoed, Withdrawn17 self.public_registration = RegistrationFactory(project=self.public_project, is_public=True)18 self.registration_of_components = RegistrationFactory(project=self.private_project, is_public=True)19 registration_of_component = self.private_component.registrations_all[0]20 registration_of_component.is_public = True21 registration_of_component.save()22 self.embargoed_registration = RegistrationFactory(project=self.public_project, creator=self.public_project.creator)23 self.embargoed_registration.embargo_registration(24 self.embargoed_registration.creator,25 timezone.now() + datetime.timedelta(days=10)26 )27 self.embargoed_registration.save()28 self.reg_to_be_withdrawn = RegistrationFactory(project=self.public_project)29 self.withdrawn_registration = WithdrawnRegistrationFactory(30 registration=self.reg_to_be_withdrawn,31 user=self.reg_to_be_withdrawn.creator32 )33 # Add Deleted Nodes34 self.deleted_node = ProjectFactory(is_deleted=True)35 self.deleted_node2 = ProjectFactory(is_deleted=True)36 self.date = timezone.now() - datetime.timedelta(days=1)37 for node in AbstractNode.objects.all():38 node.created = self.date39 node.save()40 # modify_node_dates_in_mongo(self.date - datetime.timedelta(0.1))41 self.results = NodeSummary().get_events(self.date.date())[0]42 def test_counts(self):43 # test_get_node_count44 nodes = self.results['nodes']45 assert_equal(nodes['total'], 3) # 2 Projects, 1 component46 assert_equal(nodes['public'], 1) # 1 Project47 assert_equal(nodes['private'], 2) # 1 Project, 1 Component48 assert_equal(nodes['total_daily'], 3) # 2 Projects, 1 component49 assert_equal(nodes['public_daily'], 1) # 1 Project50 assert_equal(nodes['private_daily'], 2) # 1 Project, 1 Component51 # test_get_project_count52 projects = self.results['projects']53 assert_equal(projects['total'], 2)54 assert_equal(projects['public'], 1)55 assert_equal(projects['private'], 1)56 assert_equal(projects['total_daily'], 2)57 assert_equal(projects['public_daily'], 1)58 assert_equal(projects['private_daily'], 1)59 # test_get_registered_nodes_count60 registered_nodes = self.results['registered_nodes']61 assert_equal(registered_nodes['total'], 5)62 assert_equal(registered_nodes['public'], 4) # 3 Registrations, 1 Withdrawn registration63 assert_equal(registered_nodes['withdrawn'], 1)64 assert_equal(registered_nodes['embargoed'], 1)65 assert_equal(registered_nodes['embargoed_v2'], 1)66 assert_equal(registered_nodes['total_daily'], 5)67 assert_equal(registered_nodes['public_daily'], 4) # 3 Registrations, 1 Withdrawn registration68 assert_equal(registered_nodes['withdrawn_daily'], 1)69 assert_equal(registered_nodes['embargoed_daily'], 1)70 assert_equal(registered_nodes['embargoed_v2_daily'], 1)71 # test_get_registered_projects_count72 registered_projects = self.results['registered_projects']73 assert_equal(registered_projects['total'], 4) # Not including a Registration Component74 assert_equal(registered_projects['public'], 3)75 assert_equal(registered_projects['withdrawn'], 1)76 assert_equal(registered_projects['embargoed'], 1)77 assert_equal(registered_projects['embargoed_v2'], 1)78 assert_equal(registered_projects['total_daily'], 4)79 assert_equal(registered_projects['public_daily'], 3)80 assert_equal(registered_projects['withdrawn_daily'], 1)81 assert_equal(registered_projects['embargoed_daily'], 1)82 assert_equal(registered_projects['embargoed_v2_daily'], 1)83 # Modify date to zero out dailies84 for node in AbstractNode.objects.all():85 node.created = self.date - datetime.timedelta(days=1)86 node.save()87 self.results = NodeSummary().get_events(self.date.date())[0]88 # test_get_node_count daily zero89 nodes = self.results['nodes']90 assert_equal(nodes['total'], 3) # 2 Projects, 1 component91 assert_equal(nodes['public'], 1) # 1 Project92 assert_equal(nodes['private'], 2) # 1 Project, 1 Component93 assert_equal(nodes['total_daily'], 0) # 2 Projects, 1 component94 assert_equal(nodes['public_daily'], 0) # 1 Project95 assert_equal(nodes['private_daily'], 0) # 1 Project, 1 Component96 # test_get_project_count daily zero97 projects = self.results['projects']98 assert_equal(projects['total'], 2)99 assert_equal(projects['public'], 1)100 assert_equal(projects['private'], 1)101 assert_equal(projects['total_daily'], 0)102 assert_equal(projects['public_daily'], 0)103 assert_equal(projects['private_daily'], 0)104 # test_get_registered_nodes_count daily zero105 registered_nodes = self.results['registered_nodes']106 assert_equal(registered_nodes['total'], 5)107 assert_equal(registered_nodes['public'], 4) # 3 Registrations, 1 Withdrawn registration108 assert_equal(registered_nodes['withdrawn'], 1)109 assert_equal(registered_nodes['embargoed'], 1)110 assert_equal(registered_nodes['embargoed_v2'], 1)111 assert_equal(registered_nodes['total_daily'], 0)112 assert_equal(registered_nodes['public_daily'], 0) # 3 Registrations, 1 Withdrawn registration113 assert_equal(registered_nodes['withdrawn_daily'], 0)114 assert_equal(registered_nodes['embargoed_daily'], 0)115 assert_equal(registered_nodes['embargoed_v2_daily'], 0)116 # test_get_registered_projects_count daily zero117 registered_projects = self.results['registered_projects']118 assert_equal(registered_projects['total'], 4) # Not including a Registration Component119 assert_equal(registered_projects['public'], 3)120 assert_equal(registered_projects['withdrawn'], 1)121 assert_equal(registered_projects['embargoed'], 1)122 assert_equal(registered_projects['embargoed_v2'], 1)123 assert_equal(registered_projects['total_daily'], 0)124 assert_equal(registered_projects['public_daily'], 0)125 assert_equal(registered_projects['withdrawn_daily'], 0)126 assert_equal(registered_projects['embargoed_daily'], 0)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run dbt-osmosis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful