<s> import pytest <EOL> from comport . content . models import ChartBlock <EOL> from comport . department . models import Extractor <EOL> from . factories import DepartmentFactory <EOL> import uuid <EOL> @ pytest . mark . usefixtures ( '<STR_LIT>' ) <EOL> class TestExtractors : <EOL> def test_extractors_from_department_and_password ( self ) : <EOL> department = DepartmentFactory ( ) <EOL> department . save ( ) <EOL> password = str ( uuid . uuid4 ( ) ) <EOL> extractor , envs = Extractor . from_department_and_password ( department = department , password = password ) <EOL> assert department == extractor . departments [ <NUM_LIT:0> ] <EOL> assert extractor . check_password ( password ) is True <EOL> assert password in envs <EOL> def test_get_extractor_from_department ( self ) : <EOL> department = DepartmentFactory ( ) <EOL> department . save ( ) <EOL> assert ( "<STR_LIT:U+0020>" in department . name ) is True <EOL> password = str ( uuid . uuid4 ( ) ) <EOL> extractor , envs = Extractor . from_department_and_password ( department = department , password = password ) <EOL> extractor . save ( ) <EOL> assert department . get_extractor ( ) == extractor <EOL> assert ( "<STR_LIT:U+0020>" in extractor . username ) is False <EOL> def test_regen_extractor_envs ( self ) : <EOL> department = DepartmentFactory ( ) <EOL> department . save ( ) <EOL> password = str ( uuid . uuid4 ( ) ) <EOL> extractor , envs = Extractor . from_department_and_password ( department = department , password = password ) <EOL> extractor . save ( ) <EOL> new_password = str ( uuid . uuid4 ( ) ) <EOL> extractor . set_password ( new_password ) <EOL> assert extractor . check_password ( new_password ) is True <EOL> assert new_password in extractor . generate_envs ( new_password ) <EOL> def test_get_extractor_from_department_without_extractor ( self ) : <EOL> department = DepartmentFactory ( ) <EOL> department . save ( ) <EOL> assert department . get_extractor ( ) == None <EOL> def test_get_complaint_blocks ( self ) : <EOL> '''<STR_LIT>''' <EOL> department = DepartmentFactory ( ) <EOL> department . save ( ) <EOL> complaint_intro = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> complaint_bm = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> complaint_bya = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> complaint_byat = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> complaint_bdis = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> complaint_bpre = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> complaint_od = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> complaint_bde = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> complaint_bof = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> department . chart_blocks . append ( complaint_intro ) <EOL> department . chart_blocks . append ( complaint_bm ) <EOL> department . chart_blocks . append ( complaint_bya ) <EOL> department . chart_blocks . append ( complaint_byat ) <EOL> department . chart_blocks . append ( complaint_bdis ) <EOL> department . chart_blocks . append ( complaint_bpre ) <EOL> department . chart_blocks . append ( complaint_od ) <EOL> department . chart_blocks . append ( complaint_bde ) <EOL> department . chart_blocks . append ( complaint_bof ) <EOL> department . save ( ) <EOL> complaint_blocks = department . get_complaint_blocks ( ) <EOL> assert complaint_blocks [ '<STR_LIT>' ] == complaint_intro <EOL> assert complaint_blocks [ '<STR_LIT>' ] == complaint_bm <EOL> assert complaint_blocks [ '<STR_LIT>' ] [ <NUM_LIT:0> ] == complaint_bya <EOL> assert complaint_blocks [ '<STR_LIT>' ] [ <NUM_LIT:1> ] == complaint_byat <EOL> assert complaint_blocks [ '<STR_LIT>' ] [ <NUM_LIT:2> ] == complaint_bdis <EOL> assert complaint_blocks [ '<STR_LIT>' ] [ <NUM_LIT:3> ] == complaint_bpre <EOL> assert complaint_blocks [ '<STR_LIT>' ] [ <NUM_LIT:4> ] == complaint_od <EOL> assert complaint_blocks [ '<STR_LIT>' ] [ <NUM_LIT:5> ] == complaint_bde <EOL> assert complaint_blocks [ '<STR_LIT>' ] [ <NUM_LIT:6> ] == complaint_bof <EOL> def test_get_uof_blocks ( self ) : <EOL> '''<STR_LIT>''' <EOL> department = DepartmentFactory ( ) <EOL> department . save ( ) <EOL> uof_intro = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> uof_ft = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> uof_bid = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> uof_od = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> uof_race = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> department . chart_blocks . append ( uof_intro ) <EOL> department . chart_blocks . append ( uof_ft ) <EOL> department . chart_blocks . append ( uof_bid ) <EOL> department . chart_blocks . append ( uof_od ) <EOL> department . chart_blocks . append ( uof_race ) <EOL> department . save ( ) <EOL> uof_blocks = department . get_uof_blocks ( ) <EOL> assert uof_blocks [ '<STR_LIT>' ] == uof_intro <EOL> assert uof_blocks [ '<STR_LIT>' ] == uof_ft <EOL> assert uof_blocks [ '<STR_LIT>' ] [ <NUM_LIT:0> ] == uof_bid <EOL> assert uof_blocks [ '<STR_LIT>' ] [ <NUM_LIT:1> ] == uof_od <EOL> assert uof_blocks [ '<STR_LIT>' ] [ <NUM_LIT:2> ] == uof_race <EOL> def test_get_ois_blocks ( self ) : <EOL> '''<STR_LIT>''' <EOL> department = DepartmentFactory ( ) <EOL> department . save ( ) <EOL> ois_intro = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> ois_bid = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> ois_wt = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> ois_od = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> ois_race = ChartBlock ( title = "<STR_LIT>" , dataset = "<STR_LIT>" , slug = "<STR_LIT>" ) <EOL> department . chart_blocks . append ( ois_intro ) <EOL> department . chart_blocks . append ( ois_bid ) <EOL> department . chart_blocks . append ( ois_wt ) <EOL> department . chart_blocks . append ( ois_od ) <EOL> department . chart_blocks . append ( ois_race ) <EOL> department . save ( ) <EOL> ois_blocks = department . get_ois_blocks ( ) <EOL> assert ois_blocks [ '<STR_LIT>' ] == ois_intro <EOL> assert ois_blocks [ '<STR_LIT>' ] == ois_bid <EOL> assert ois_blocks [ '<STR_LIT>' ] [ <NUM_LIT:0> ] == ois_wt <EOL> assert ois_blocks [ '<STR_LIT>' ] [ <NUM_LIT:1> ] == ois_od <EOL> assert ois_blocks [ '<STR_LIT>' ] [ <NUM_LIT:2> ] == ois_race </s>
