def test_03(self):
     iterator = discograph.Bootstrapper.get_iterator('label')
     element = next(iterator)
     entity = discograph.PostgresEntity.from_element(element)
     actual = stringtools.normalize(format(entity))
     expected = stringtools.normalize(r"""
         discograph.library.PostgresEntity(
             entities={
                 },
             entity_id=1,
             entity_type=2,
             metadata={
                 'profile': 'Classic Techno label from Detroit, USA.\r\n[b]Label owner:[/b] [a=Carl Craig].\r\n',
                 'urls': [
                     'http://www.planet-e.net/',
                     'http://www.myspace.com/planetecom',
                     'http://www.facebook.com/planetedetroit ',
                     'http://twitter.com/planetedetroit',
                     'http://soundcloud.com/planetedetroit',
                     ],
                 },
             name='Planet E',
             )
         """)
     assert actual == expected
 def test_02(self):
     iterator = discograph.Bootstrapper.get_iterator('artist')
     element = next(iterator)
     while element.find('name').text != 'Seefeel':
         element = next(iterator)
     entity = discograph.PostgresEntity.from_element(element)
     actual = stringtools.normalize(format(entity))
     expected = stringtools.normalize(u"""
         discograph.library.PostgresEntity(
             entities={
                 'members': {
                     'Daren Seymour': 66803,
                     'Justin Fletcher': 489350,
                     'Mark Clifford': 51674,
                     'Mark Van Hoen': 41103,
                     'Sarah Peacock': 115880,
                     },
                 },
             entity_id=2239,
             entity_type=1,
             metadata={
                 'profile': 'British electronic/rock group formed in the early 1990s. They are currently signed to Warp Records.',
                 'real_name': 'Sarah Peacock, Mark Clifford, Darren Seymour & Justin Fletcher',
                 'urls': [
                     'http://www.myspace.com/seefeelmyspace',
                     'http://en.wikipedia.org/wiki/Seefeel',
                     'http://www.facebook.com/pages/Seefeel/146206372061290',
                     'http://twitter.com/#!/_Seefeel_',
                     'http://bit.ly/mQ9t3F',
                     'http://www.seefeel.org',
                     ],
                 },
             name='Seefeel',
             )
         """)
Example #3
0
 def test_02(self):
     iterator = discograph.Bootstrapper.get_iterator('artist')
     element = next(iterator)
     while element.find('name').text != 'Seefeel':
         element = next(iterator)
     entity = discograph.PostgresEntity.from_element(element)
     actual = stringtools.normalize(format(entity))
     expected = stringtools.normalize(u"""
         discograph.library.PostgresEntity(
             entities={
                 'members': {
                     'Daren Seymour': 66803,
                     'Justin Fletcher': 489350,
                     'Mark Clifford': 51674,
                     'Mark Van Hoen': 41103,
                     'Sarah Peacock': 115880,
                     },
                 },
             entity_id=2239,
             entity_type=1,
             metadata={
                 'profile': 'British electronic/rock group formed in the early 1990s. They are currently signed to Warp Records.',
                 'real_name': 'Sarah Peacock, Mark Clifford, Darren Seymour & Justin Fletcher',
                 'urls': [
                     'http://www.myspace.com/seefeelmyspace',
                     'http://en.wikipedia.org/wiki/Seefeel',
                     'http://www.facebook.com/pages/Seefeel/146206372061290',
                     'http://twitter.com/#!/_Seefeel_',
                     'http://bit.ly/mQ9t3F',
                     'http://www.seefeel.org',
                     ],
                 },
             name='Seefeel',
             )
         """)
Example #4
0
 def test_03(self):
     iterator = discograph.Bootstrapper.get_iterator('label')
     element = next(iterator)
     entity = discograph.PostgresEntity.from_element(element)
     actual = stringtools.normalize(format(entity))
     expected = stringtools.normalize(r"""
         discograph.library.PostgresEntity(
             entities={
                 },
             entity_id=1,
             entity_type=2,
             metadata={
                 'profile': 'Classic Techno label from Detroit, USA.\r\n[b]Label owner:[/b] [a=Carl Craig].\r\n',
                 'urls': [
                     'http://www.planet-e.net/',
                     'http://www.myspace.com/planetecom',
                     'http://www.facebook.com/planetedetroit ',
                     'http://twitter.com/planetedetroit',
                     'http://soundcloud.com/planetedetroit',
                     ],
                 },
             name='Planet E',
             )
         """)
     assert actual == expected
 def test_01(self):
     iterator = discograph.Bootstrapper.get_iterator('artist')
     element = next(iterator)
     entity = discograph.PostgresEntity.from_element(element)
     actual = stringtools.normalize(format(entity))
     expected = stringtools.normalize(u"""
         discograph.library.PostgresEntity(
             entities={
                 'aliases': {
                     },
                 'groups': {
                     },
                 },
             entity_id=3,
             entity_type=1,
             metadata={
                 'name_variations': [
                     'DJ Josh Wink',
                     'DJ Wink',
                     'J Wink',
                     'J. Wink',
                     'J. Wink (DJ  Wink)',
                     'J. Winkelman',
                     'J. Winkelmann',
                     'J.Wink',
                     'J.Winkelman',
                     'Josh',
                     'Josh Wink (DJ Wink)',
                     'Josh Wink Aka Winx',
                     'Josh Winkelman',
                     'Josh Winkelmann',
                     'Josh Winx',
                     'JW',
                     'Unknown Artist',
                     'Winc',
                     'Wink',
                     'Wink (Feat The Interpreters)',
                     'Winks',
                     'Winx',
                     'Winxs',
                     ],
                 'profile': "After forming [l=Ovum Recordings] as an independent label in October 1994 with former partner [a=King Britt], Josh recorded the cult classic 'Liquid Summer'. He went on to release singles for a wide variety of revered European labels ranging from Belgium's [l=R & S Records] to England's [l=XL Recordings]. In 1995, Wink became one of the first DJ-producers to translate his hard work into mainstream success when he unleashed a string of classics including 'Don't Laugh'¸ 'I'm Ready' and 'Higher State of Consciousness' that topped charts worldwide. More recently he has had massive club hits such as 'How's Your Evening So Far' and 'Superfreak' but he has also gained a lot of attention trough his remixes for [a=FC Kahuna], [a=Paul Oakenfold], [a=Ladytron], [a=Clint Mansell], [a=Sting] and [a=Depeche Mode], among others.",
                 'real_name': 'Joshua Winkelman',
                 'urls': [
                     'http://www.joshwink.com/',
                     'http://www.ovum-rec.com/',
                     'http://www.myspace.com/joshwink',
                     'http://www.myspace.com/ovumrecordings',
                     'http://www.deejaybooking.com/joshwink',
                     'http://twitter.com/joshwink1',
                     ],
                 },
             name='Josh Wink',
             )
         """)
     assert actual == expected
Example #6
0
 def test_01(self):
     iterator = discograph.Bootstrapper.get_iterator('artist')
     element = next(iterator)
     entity = discograph.PostgresEntity.from_element(element)
     actual = stringtools.normalize(format(entity))
     expected = stringtools.normalize(u"""
         discograph.library.PostgresEntity(
             entities={
                 'aliases': {
                     },
                 'groups': {
                     },
                 },
             entity_id=3,
             entity_type=1,
             metadata={
                 'name_variations': [
                     'DJ Josh Wink',
                     'DJ Wink',
                     'J Wink',
                     'J. Wink',
                     'J. Wink (DJ  Wink)',
                     'J. Winkelman',
                     'J. Winkelmann',
                     'J.Wink',
                     'J.Winkelman',
                     'Josh',
                     'Josh Wink (DJ Wink)',
                     'Josh Wink Aka Winx',
                     'Josh Winkelman',
                     'Josh Winkelmann',
                     'Josh Winx',
                     'JW',
                     'Unknown Artist',
                     'Winc',
                     'Wink',
                     'Wink (Feat The Interpreters)',
                     'Winks',
                     'Winx',
                     'Winxs',
                     ],
                 'profile': "After forming [l=Ovum Recordings] as an independent label in October 1994 with former partner [a=King Britt], Josh recorded the cult classic 'Liquid Summer'. He went on to release singles for a wide variety of revered European labels ranging from Belgium's [l=R & S Records] to England's [l=XL Recordings]. In 1995, Wink became one of the first DJ-producers to translate his hard work into mainstream success when he unleashed a string of classics including 'Don't Laugh'¸ 'I'm Ready' and 'Higher State of Consciousness' that topped charts worldwide. More recently he has had massive club hits such as 'How's Your Evening So Far' and 'Superfreak' but he has also gained a lot of attention trough his remixes for [a=FC Kahuna], [a=Paul Oakenfold], [a=Ladytron], [a=Clint Mansell], [a=Sting] and [a=Depeche Mode], among others.",
                 'real_name': 'Joshua Winkelman',
                 'urls': [
                     'http://www.joshwink.com/',
                     'http://www.ovum-rec.com/',
                     'http://www.myspace.com/joshwink',
                     'http://www.myspace.com/ovumrecordings',
                     'http://www.deejaybooking.com/joshwink',
                     'http://twitter.com/joshwink1',
                     ],
                 },
             name='Josh Wink',
             )
         """)
     assert actual == expected
    def test_01(self):
        iterator = Bootstrapper.get_iterator('label')
        label_element = next(iterator)
        label_element = next(iterator)
        label_element = next(iterator)
        actual = stringtools.normalize(Bootstrapper.prettify(label_element))
        expected = stringtools.normalize(u'''
            <?xml version="1.0" ?>
            <label>
                <id>3</id>
                <name>Seasons Recordings</name>
                <contactinfo>Seasons Recordings
            2236 Pacific Avenue
            Suite D
            Costa Mesa, CA 92627

            Jamie Thinnes

            Tel: 949-574-5255
            Fax: 949-574-0255

            [email protected]
            [email protected]
            </contactinfo>
                <profile>California Deep-House Label Founded By Jamie Thinnes.
            The First 10 Records Were Released on [l=Earthtones Recordings]
            </profile>
                <data_quality>Correct</data_quality>
                <sublabels>
                    <label>Seasons Classics</label>
                    <label>Seasons Limited</label>
                </sublabels>
            </label>
            ''')
        assert actual.splitlines() == expected.splitlines()
        label_document = library.Label.from_element(label_element)
        actual = format(label_document)
        expected = stringtools.normalize(u'''
            discograph.library.mongo.Label(
                discogs_id=3,
                name='Seasons Recordings',
                sublabels=[
                    discograph.library.mongo.LabelReference(
                        name='Seasons Classics',
                        ),
                    discograph.library.mongo.LabelReference(
                        name='Seasons Limited',
                        ),
                    ],
                )
            ''')
        assert actual == expected
 def test___call___01(self):
     print(discograph.PostgresEntity._meta.database)
     artist = discograph.PostgresEntity.get(entity_type=1, name='Seefeel')
     roles = ['Alias', 'Member Of']
     grapher = discograph.RelationGrapher(
         artist,
         degree=1,
         roles=roles,
         )
     network = grapher.__call__()
     actual = json.dumps(network, **self.json_kwargs)
     expected = stringtools.normalize('''
         {
             "center": {
                 "key": "artist-152882", 
                 "name": "Morris Day"
             },
             "links": [
                 {
                     "key": "artist-152882-member-of-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-152882",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-152882-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-152882",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-32550-alias-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Alias",
                     "source": "artist-32550",
                     "target": "artist-2561672"
                 }
             ],
             "nodes": [
                 {
                     "cluster": 1,
                     "distance": 1,
                     "id": 32550,
                     "key": "artist-32550",
                     "links": [
                         "artist-152882-member-of-artist-32550",
                         "artist-32550-alias-artist-2561672"
                     ],
                     "missing": 10,
                     "name": "The Time",
                     "pages": [
                         1
                     ],
                     "size": 11,
                     "type": "artist"
                 },
                 {
                     "distance": 0,
                     "id": 152882,
                     "key": "artist-152882",
                     "links": [
                         "artist-152882-member-of-artist-2561672",
                         "artist-152882-member-of-artist-32550"
                     ],
                     "missing": 0,
                     "name": "Morris Day",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "cluster": 1,
                     "distance": 1,
                     "id": 2561672,
                     "key": "artist-2561672",
                     "links": [
                         "artist-152882-member-of-artist-2561672",
                         "artist-32550-alias-artist-2561672"
                     ],
                     "missing": 6,
                     "name": "The Original 7ven",
                     "pages": [
                         1
                     ],
                     "size": 7,
                     "type": "artist"
                 }
             ],
             "pages": 1
         }
     ''')
     assert actual == expected
Example #9
0
 def test_01(self):
     iterator = Bootstrapper.get_iterator('release')
     release_element = next(iterator)
     release = discograph.PostgresRelease.from_element(release_element)
     actual = format(release)
     expected = stringtools.normalize(u"""
         discograph.library.PostgresRelease(
             artists=[
                 {
                     'id': 1,
                     'join': ',',
                     'name': 'The Persuader',
                     },
                 ],
             companies=[
                 {
                     'entity_type': 23,
                     'entity_type_name': 'Recorded At',
                     'id': 271046,
                     'name': 'The Globe Studios',
                     },
                 {
                     'entity_type': 17,
                     'entity_type_name': 'Pressed By',
                     'id': 56025,
                     'name': 'MPO',
                     },
                 ],
             country='Sweden',
             extra_artists=[
                 {
                     'id': 239,
                     'name': 'Jesper Dahlbäck',
                     'roles': [
                         {
                             'detail': 'All Tracks By',
                             'name': 'Music By',
                             },
                         ],
                     },
                 ],
             formats=[
                 {
                     'descriptions': ['12"', '33 ⅓ RPM'],
                     'name': 'Vinyl',
                     'quantity': '2',
                     },
                 ],
             genres=['Electronic'],
             id=1,
             identifiers=[
                 {
                     'description': 'A-Side',
                     'type': 'Matrix / Runout',
                     'value': 'MPO SK 032 A1 G PHRUPMASTERGENERAL T27 LONDON',
                     },
                 {
                     'description': 'B-Side',
                     'type': 'Matrix / Runout',
                     'value': 'MPO SK 032 B1',
                     },
                 {
                     'description': 'C-Side',
                     'type': 'Matrix / Runout',
                     'value': 'MPO SK 032 C1',
                     },
                 {
                     'description': 'D-Side',
                     'type': 'Matrix / Runout',
                     'value': 'MPO SK 032 D1',
                     },
                 ],
             labels=[
                 {
                     'catalog_number': 'SK032',
                     'name': 'Svek',
                     },
                 ],
             release_date=datetime.datetime(1999, 3, 1, 0, 0),
             styles=['Deep House'],
             title='Stockholm',
             tracklist=[
                 {
                     'duration': '4:45',
                     'position': 'A',
                     'title': 'Östermalm',
                     },
                 {
                     'duration': '6:11',
                     'position': 'B1',
                     'title': 'Vasastaden',
                     },
                 {
                     'duration': '2:49',
                     'position': 'B2',
                     'title': 'Kungsholmen',
                     },
                 {
                     'duration': '5:38',
                     'position': 'C1',
                     'title': 'Södermalm',
                     },
                 {
                     'duration': '4:52',
                     'position': 'C2',
                     'title': 'Norrmalm',
                     },
                 {
                     'duration': '5:16',
                     'position': 'D',
                     'title': 'Gamla Stan',
                     },
                 ],
             )
         """)
     assert actual == expected
Example #10
0
 def test_02(self):
     iterator = Bootstrapper.get_iterator('release')
     release_element = next(iterator)
     release_element = next(iterator)
     release_element = next(iterator)
     release = discograph.PostgresRelease.from_element(release_element)
     actual = format(release)
     expected = stringtools.normalize(r'''
         discograph.library.PostgresRelease(
             artists=[
                 {
                     'id': 3,
                     'name': 'Josh Wink',
                     },
                 ],
             companies=[
                 {
                     'entity_type': 10,
                     'entity_type_name': 'Manufactured By',
                     'id': 93330,
                     'name': 'Columbia Records',
                     },
                 {
                     'entity_type': 9,
                     'entity_type_name': 'Distributed By',
                     'id': 93330,
                     'name': 'Columbia Records',
                     },
                 ],
             country='US',
             extra_artists=[
                 {
                     'id': 3,
                     'name': 'Josh Wink',
                     'roles': [
                         {
                             'name': 'DJ Mix',
                             },
                         ],
                     },
                 ],
             formats=[
                 {
                     'descriptions': ['Compilation', 'Mixed'],
                     'name': 'CD',
                     'quantity': '1',
                     },
                 ],
             genres=['Electronic'],
             id=3,
             identifiers=[
                 {
                     'description': None,
                     'type': 'Barcode',
                     'value': '074646362822',
                     },
                 ],
             labels=[
                 {
                     'catalog_number': 'CK 63628',
                     'name': 'Ruffhouse Records',
                     },
                 ],
             master_id=66526,
             release_date=datetime.datetime(1999, 7, 13, 0, 0),
             styles=['Techno', 'Tech House'],
             title='Profound Sounds Vol. 1',
             tracklist=[
                 {
                     'artists': [
                         {
                             'id': 5,
                             'join': '&',
                             'name': 'Heiko Laux',
                             },
                         {
                             'id': 4,
                             'join': ',',
                             'name': 'Johannes Heil',
                             },
                         ],
                     'duration': '7:00',
                     'position': '1',
                     'title': 'Untitled 8',
                     },
                 {
                     'artists': [
                         {
                             'anv': 'K.A.B.',
                             'id': 15525,
                             'join': ',',
                             'name': 'Karl Axel Bissler',
                             },
                         ],
                     'duration': '5:28',
                     'position': '2',
                     'title': 'Anjua (Sneaky 3)',
                     },
                 {
                     'artists': [
                         {
                             'id': 7,
                             'join': ',',
                             'name': 'Sylk 130',
                             },
                         ],
                     'duration': '5:25',
                     'extra_artists': [
                         {
                             'id': 8,
                             'name': 'Mood II Swing',
                             'roles': [
                                 {
                                     'name': 'Remix',
                                     },
                                 ],
                             },
                         ],
                     'position': '3',
                     'title': 'When The Funk Hits The Fan (Mood II Swing When The Dub Hits The Fan)',
                     },
                 {
                     'artists': [
                         {
                             'id': 1,
                             'join': ',',
                             'name': 'The Persuader',
                             },
                         ],
                     'duration': '4:27',
                     'position': '4',
                     'title': "What's The Time, Mr. Templar",
                     },
                 {
                     'artists': [
                         {
                             'id': 267132,
                             'join': ',',
                             'name': 'Care Company (2)',
                             },
                         ],
                     'duration': '5:36',
                     'position': '5',
                     'title': 'Vol. 2',
                     },
                 {
                     'artists': [
                         {
                             'id': 6981,
                             'join': ',',
                             'name': 'Gez Varley',
                             },
                         ],
                     'duration': '3:37',
                     'position': '6',
                     'title': 'Political Prisoner',
                     },
                 {
                     'artists': [
                         {
                             'id': 11,
                             'join': ',',
                             'name': 'DJ Dozia',
                             },
                         ],
                     'duration': '5:03',
                     'position': '7',
                     'title': 'Pop Kulture',
                     },
                 {
                     'artists': [
                         {
                             'id': 10702,
                             'join': 'Meets',
                             'name': "Nerio's Dubwork",
                             },
                         {
                             'id': 233190,
                             'join': ',',
                             'name': 'Kathy Lee',
                             },
                         ],
                     'duration': '5:42',
                     'extra_artists': [
                         {
                             'id': 23,
                             'name': 'Alex Hi-Fi',
                             'roles': [
                                 {
                                     'name': 'Remix',
                                     },
                                 ],
                             },
                         ],
                     'position': '8',
                     'title': 'K-Mart Shopping (Hi-Fi Mix)',
                     },
                 {
                     'artists': [
                         {
                             'id': 13,
                             'join': ',',
                             'name': 'Blaze',
                             },
                         ],
                     'duration': '5:47',
                     'extra_artists': [
                         {
                             'id': 14,
                             'name': 'Eight Miles High',
                             'roles': [
                                 {
                                     'name': 'Remix',
                                     },
                                 ],
                             },
                         ],
                     'position': '9',
                     'title': 'Lovelee Dae (Eight Miles High Mix)',
                     },
                 {
                     'artists': [
                         {
                             'id': 67226,
                             'join': 'Presents',
                             'name': 'Stacey Pullen',
                             },
                         {
                             'id': 7554,
                             'join': ',',
                             'name': 'Black Odyssey',
                             },
                         ],
                     'duration': '6:06',
                     'extra_artists': [
                         {
                             'id': 67226,
                             'name': 'Stacey Pullen',
                             'roles': [
                                 {
                                     'name': 'Presenter',
                                     },
                                 ],
                             },
                         ],
                     'position': '10',
                     'title': 'Sweat',
                     },
                 {
                     'artists': [
                         {
                             'id': 3906,
                             'join': ',',
                             'name': 'Christian Smith & John Selway',
                             },
                         ],
                     'duration': '3:16',
                     'position': '11',
                     'title': 'Silver',
                     },
                 {
                     'artists': [
                         {
                             'id': 3,
                             'join': ',',
                             'name': 'Josh Wink',
                             },
                         ],
                     'duration': '2:46',
                     'position': '12',
                     'title': 'Untitled',
                     },
                 {
                     'artists': [
                         {
                             'id': 19,
                             'join': ',',
                             'name': 'Sound Associates',
                             },
                         ],
                     'duration': '3:41',
                     'position': '13',
                     'title': 'Boom Box',
                     },
                 {
                     'artists': [
                         {
                             'id': 20,
                             'join': ',',
                             'name': 'Percy X',
                             },
                         ],
                     'duration': '3:39',
                     'position': '14',
                     'title': 'Track 2',
                     },
                 ],
             )
         ''')
     assert actual == expected
Example #11
0
 def test___call___01(self):
     print(discograph.PostgresEntity._meta.database)
     artist = discograph.PostgresEntity.get(entity_type=1, name='Seefeel')
     roles = ['Alias', 'Member Of']
     grapher = discograph.RelationGrapher(
         artist,
         degree=1,
         roles=roles,
     )
     network = grapher.__call__()
     actual = json.dumps(network, **self.json_kwargs)
     expected = stringtools.normalize('''
         {
             "center": {
                 "key": "artist-152882", 
                 "name": "Morris Day"
             },
             "links": [
                 {
                     "key": "artist-152882-member-of-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-152882",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-152882-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-152882",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-32550-alias-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Alias",
                     "source": "artist-32550",
                     "target": "artist-2561672"
                 }
             ],
             "nodes": [
                 {
                     "cluster": 1,
                     "distance": 1,
                     "id": 32550,
                     "key": "artist-32550",
                     "links": [
                         "artist-152882-member-of-artist-32550",
                         "artist-32550-alias-artist-2561672"
                     ],
                     "missing": 10,
                     "name": "The Time",
                     "pages": [
                         1
                     ],
                     "size": 11,
                     "type": "artist"
                 },
                 {
                     "distance": 0,
                     "id": 152882,
                     "key": "artist-152882",
                     "links": [
                         "artist-152882-member-of-artist-2561672",
                         "artist-152882-member-of-artist-32550"
                     ],
                     "missing": 0,
                     "name": "Morris Day",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "cluster": 1,
                     "distance": 1,
                     "id": 2561672,
                     "key": "artist-2561672",
                     "links": [
                         "artist-152882-member-of-artist-2561672",
                         "artist-32550-alias-artist-2561672"
                     ],
                     "missing": 6,
                     "name": "The Original 7ven",
                     "pages": [
                         1
                     ],
                     "size": 7,
                     "type": "artist"
                 }
             ],
             "pages": 1
         }
     ''')
     assert actual == expected
 def test___call___03(self):
     artist = discograph.PostgresEntity.get(entity_type=1, name='Morris Day')
     roles = ['Alias', 'Member Of']
     grapher = discograph.RelationGrapher(
         artist,
         degree=2,
         link_ratio=2,
         roles=roles,
         )
     network = grapher.__call__()
     actual = json.dumps(network, **self.json_kwargs)
     expected = stringtools.normalize('''
         {
             "center": {
                 "key": "artist-152882",
                 "name": "Morris Day"
             },
             "links": [
                 {
                     "key": "artist-100600-member-of-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-100600",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-100600-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-100600",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-113965-member-of-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-113965",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-113965-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-113965",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-152882-member-of-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-152882",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-152882-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-152882",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-23446-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-23446",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-241356-member-of-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-241356",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-241356-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-241356",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-242702-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-242702",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-32550-alias-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Alias",
                     "source": "artist-32550",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-354129-member-of-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-354129",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-354129-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-354129",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-37806-member-of-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-37806",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-37806-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-37806",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-409502-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-409502",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-453969-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-453969",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-55449-member-of-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-55449",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-55449-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-55449",
                     "target": "artist-32550"
                 }
             ],
             "nodes": [
                 {
                     "distance": 2,
                     "id": 23446,
                     "key": "artist-23446",
                     "links": [
                         "artist-23446-member-of-artist-32550"
                     ],
                     "missing": 1,
                     "name": "Alexander O'Neal",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "cluster": 1,
                     "distance": 1,
                     "id": 32550,
                     "key": "artist-32550",
                     "links": [
                         "artist-100600-member-of-artist-32550",
                         "artist-113965-member-of-artist-32550",
                         "artist-152882-member-of-artist-32550",
                         "artist-23446-member-of-artist-32550",
                         "artist-241356-member-of-artist-32550",
                         "artist-242702-member-of-artist-32550",
                         "artist-32550-alias-artist-2561672",
                         "artist-354129-member-of-artist-32550",
                         "artist-37806-member-of-artist-32550",
                         "artist-409502-member-of-artist-32550",
                         "artist-453969-member-of-artist-32550",
                         "artist-55449-member-of-artist-32550"
                     ],
                     "missing": 0,
                     "name": "The Time",
                     "pages": [
                         1
                     ],
                     "size": 11,
                     "type": "artist"
                 },
                 {
                     "distance": 2,
                     "id": 37806,
                     "key": "artist-37806",
                     "links": [
                         "artist-37806-member-of-artist-2561672",
                         "artist-37806-member-of-artist-32550"
                     ],
                     "missing": 2,
                     "name": "Jesse Johnson",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 2,
                     "id": 55449,
                     "key": "artist-55449",
                     "links": [
                         "artist-55449-member-of-artist-2561672",
                         "artist-55449-member-of-artist-32550"
                     ],
                     "missing": 3,
                     "name": "Terry Lewis",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 2,
                     "id": 100600,
                     "key": "artist-100600",
                     "links": [
                         "artist-100600-member-of-artist-2561672",
                         "artist-100600-member-of-artist-32550"
                     ],
                     "missing": 1,
                     "name": "Monte Moir",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 2,
                     "id": 113965,
                     "key": "artist-113965",
                     "links": [
                         "artist-113965-member-of-artist-2561672",
                         "artist-113965-member-of-artist-32550"
                     ],
                     "missing": 4,
                     "name": "Jellybean Johnson",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 0,
                     "id": 152882,
                     "key": "artist-152882",
                     "links": [
                         "artist-152882-member-of-artist-2561672",
                         "artist-152882-member-of-artist-32550"
                     ],
                     "missing": 0,
                     "name": "Morris Day",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "cluster": 2,
                     "distance": 2,
                     "id": 241356,
                     "key": "artist-241356",
                     "links": [
                         "artist-241356-member-of-artist-2561672",
                         "artist-241356-member-of-artist-32550"
                     ],
                     "missing": 4,
                     "name": "James Harris III",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "cluster": 3,
                     "distance": 2,
                     "id": 242702,
                     "key": "artist-242702",
                     "links": [
                         "artist-242702-member-of-artist-32550"
                     ],
                     "missing": 5,
                     "name": "Paul Peterson",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 2,
                     "id": 354129,
                     "key": "artist-354129",
                     "links": [
                         "artist-354129-member-of-artist-2561672",
                         "artist-354129-member-of-artist-32550"
                     ],
                     "missing": 1,
                     "name": "Jerome Benton",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 2,
                     "id": 409502,
                     "key": "artist-409502",
                     "links": [
                         "artist-409502-member-of-artist-32550"
                     ],
                     "missing": 1,
                     "name": "Mark Cardenas",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 2,
                     "id": 453969,
                     "key": "artist-453969",
                     "links": [
                         "artist-453969-member-of-artist-32550"
                     ],
                     "missing": 2,
                     "name": "Jerry Hubbard",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "cluster": 1,
                     "distance": 1,
                     "id": 2561672,
                     "key": "artist-2561672",
                     "links": [
                         "artist-100600-member-of-artist-2561672",
                         "artist-113965-member-of-artist-2561672",
                         "artist-152882-member-of-artist-2561672",
                         "artist-241356-member-of-artist-2561672",
                         "artist-32550-alias-artist-2561672",
                         "artist-354129-member-of-artist-2561672",
                         "artist-37806-member-of-artist-2561672",
                         "artist-55449-member-of-artist-2561672"
                     ],
                     "missing": 0,
                     "name": "The Original 7ven",
                     "pages": [
                         1
                     ],
                     "size": 7,
                     "type": "artist"
                 }
             ],
             "pages": 1
         }
     ''')
     assert actual == expected
 def test_01(self):
     iterator = Bootstrapper.get_iterator('release')
     release_element = next(iterator)
     release = discograph.PostgresRelease.from_element(release_element)
     actual = format(release)
     expected = stringtools.normalize(u"""
         discograph.library.PostgresRelease(
             artists=[
                 {
                     'id': 1,
                     'join': ',',
                     'name': 'The Persuader',
                     },
                 ],
             companies=[
                 {
                     'entity_type': 23,
                     'entity_type_name': 'Recorded At',
                     'id': 271046,
                     'name': 'The Globe Studios',
                     },
                 {
                     'entity_type': 17,
                     'entity_type_name': 'Pressed By',
                     'id': 56025,
                     'name': 'MPO',
                     },
                 ],
             country='Sweden',
             extra_artists=[
                 {
                     'id': 239,
                     'name': 'Jesper Dahlbäck',
                     'roles': [
                         {
                             'detail': 'All Tracks By',
                             'name': 'Music By',
                             },
                         ],
                     },
                 ],
             formats=[
                 {
                     'descriptions': ['12"', '33 ⅓ RPM'],
                     'name': 'Vinyl',
                     'quantity': '2',
                     },
                 ],
             genres=['Electronic'],
             id=1,
             identifiers=[
                 {
                     'description': 'A-Side',
                     'type': 'Matrix / Runout',
                     'value': 'MPO SK 032 A1 G PHRUPMASTERGENERAL T27 LONDON',
                     },
                 {
                     'description': 'B-Side',
                     'type': 'Matrix / Runout',
                     'value': 'MPO SK 032 B1',
                     },
                 {
                     'description': 'C-Side',
                     'type': 'Matrix / Runout',
                     'value': 'MPO SK 032 C1',
                     },
                 {
                     'description': 'D-Side',
                     'type': 'Matrix / Runout',
                     'value': 'MPO SK 032 D1',
                     },
                 ],
             labels=[
                 {
                     'catalog_number': 'SK032',
                     'name': 'Svek',
                     },
                 ],
             release_date=datetime.datetime(1999, 3, 1, 0, 0),
             styles=['Deep House'],
             title='Stockholm',
             tracklist=[
                 {
                     'duration': '4:45',
                     'position': 'A',
                     'title': 'Östermalm',
                     },
                 {
                     'duration': '6:11',
                     'position': 'B1',
                     'title': 'Vasastaden',
                     },
                 {
                     'duration': '2:49',
                     'position': 'B2',
                     'title': 'Kungsholmen',
                     },
                 {
                     'duration': '5:38',
                     'position': 'C1',
                     'title': 'Södermalm',
                     },
                 {
                     'duration': '4:52',
                     'position': 'C2',
                     'title': 'Norrmalm',
                     },
                 {
                     'duration': '5:16',
                     'position': 'D',
                     'title': 'Gamla Stan',
                     },
                 ],
             )
         """)
     assert actual == expected
 def test_02(self):
     iterator = Bootstrapper.get_iterator('release')
     release_element = next(iterator)
     release_element = next(iterator)
     release_element = next(iterator)
     release = discograph.PostgresRelease.from_element(release_element)
     actual = format(release)
     expected = stringtools.normalize(r'''
         discograph.library.PostgresRelease(
             artists=[
                 {
                     'id': 3,
                     'name': 'Josh Wink',
                     },
                 ],
             companies=[
                 {
                     'entity_type': 10,
                     'entity_type_name': 'Manufactured By',
                     'id': 93330,
                     'name': 'Columbia Records',
                     },
                 {
                     'entity_type': 9,
                     'entity_type_name': 'Distributed By',
                     'id': 93330,
                     'name': 'Columbia Records',
                     },
                 ],
             country='US',
             extra_artists=[
                 {
                     'id': 3,
                     'name': 'Josh Wink',
                     'roles': [
                         {
                             'name': 'DJ Mix',
                             },
                         ],
                     },
                 ],
             formats=[
                 {
                     'descriptions': ['Compilation', 'Mixed'],
                     'name': 'CD',
                     'quantity': '1',
                     },
                 ],
             genres=['Electronic'],
             id=3,
             identifiers=[
                 {
                     'description': None,
                     'type': 'Barcode',
                     'value': '074646362822',
                     },
                 ],
             labels=[
                 {
                     'catalog_number': 'CK 63628',
                     'name': 'Ruffhouse Records',
                     },
                 ],
             master_id=66526,
             release_date=datetime.datetime(1999, 7, 13, 0, 0),
             styles=['Techno', 'Tech House'],
             title='Profound Sounds Vol. 1',
             tracklist=[
                 {
                     'artists': [
                         {
                             'id': 5,
                             'join': '&',
                             'name': 'Heiko Laux',
                             },
                         {
                             'id': 4,
                             'join': ',',
                             'name': 'Johannes Heil',
                             },
                         ],
                     'duration': '7:00',
                     'position': '1',
                     'title': 'Untitled 8',
                     },
                 {
                     'artists': [
                         {
                             'anv': 'K.A.B.',
                             'id': 15525,
                             'join': ',',
                             'name': 'Karl Axel Bissler',
                             },
                         ],
                     'duration': '5:28',
                     'position': '2',
                     'title': 'Anjua (Sneaky 3)',
                     },
                 {
                     'artists': [
                         {
                             'id': 7,
                             'join': ',',
                             'name': 'Sylk 130',
                             },
                         ],
                     'duration': '5:25',
                     'extra_artists': [
                         {
                             'id': 8,
                             'name': 'Mood II Swing',
                             'roles': [
                                 {
                                     'name': 'Remix',
                                     },
                                 ],
                             },
                         ],
                     'position': '3',
                     'title': 'When The Funk Hits The Fan (Mood II Swing When The Dub Hits The Fan)',
                     },
                 {
                     'artists': [
                         {
                             'id': 1,
                             'join': ',',
                             'name': 'The Persuader',
                             },
                         ],
                     'duration': '4:27',
                     'position': '4',
                     'title': "What's The Time, Mr. Templar",
                     },
                 {
                     'artists': [
                         {
                             'id': 267132,
                             'join': ',',
                             'name': 'Care Company (2)',
                             },
                         ],
                     'duration': '5:36',
                     'position': '5',
                     'title': 'Vol. 2',
                     },
                 {
                     'artists': [
                         {
                             'id': 6981,
                             'join': ',',
                             'name': 'Gez Varley',
                             },
                         ],
                     'duration': '3:37',
                     'position': '6',
                     'title': 'Political Prisoner',
                     },
                 {
                     'artists': [
                         {
                             'id': 11,
                             'join': ',',
                             'name': 'DJ Dozia',
                             },
                         ],
                     'duration': '5:03',
                     'position': '7',
                     'title': 'Pop Kulture',
                     },
                 {
                     'artists': [
                         {
                             'id': 10702,
                             'join': 'Meets',
                             'name': "Nerio's Dubwork",
                             },
                         {
                             'id': 233190,
                             'join': ',',
                             'name': 'Kathy Lee',
                             },
                         ],
                     'duration': '5:42',
                     'extra_artists': [
                         {
                             'id': 23,
                             'name': 'Alex Hi-Fi',
                             'roles': [
                                 {
                                     'name': 'Remix',
                                     },
                                 ],
                             },
                         ],
                     'position': '8',
                     'title': 'K-Mart Shopping (Hi-Fi Mix)',
                     },
                 {
                     'artists': [
                         {
                             'id': 13,
                             'join': ',',
                             'name': 'Blaze',
                             },
                         ],
                     'duration': '5:47',
                     'extra_artists': [
                         {
                             'id': 14,
                             'name': 'Eight Miles High',
                             'roles': [
                                 {
                                     'name': 'Remix',
                                     },
                                 ],
                             },
                         ],
                     'position': '9',
                     'title': 'Lovelee Dae (Eight Miles High Mix)',
                     },
                 {
                     'artists': [
                         {
                             'id': 67226,
                             'join': 'Presents',
                             'name': 'Stacey Pullen',
                             },
                         {
                             'id': 7554,
                             'join': ',',
                             'name': 'Black Odyssey',
                             },
                         ],
                     'duration': '6:06',
                     'extra_artists': [
                         {
                             'id': 67226,
                             'name': 'Stacey Pullen',
                             'roles': [
                                 {
                                     'name': 'Presenter',
                                     },
                                 ],
                             },
                         ],
                     'position': '10',
                     'title': 'Sweat',
                     },
                 {
                     'artists': [
                         {
                             'id': 3906,
                             'join': ',',
                             'name': 'Christian Smith & John Selway',
                             },
                         ],
                     'duration': '3:16',
                     'position': '11',
                     'title': 'Silver',
                     },
                 {
                     'artists': [
                         {
                             'id': 3,
                             'join': ',',
                             'name': 'Josh Wink',
                             },
                         ],
                     'duration': '2:46',
                     'position': '12',
                     'title': 'Untitled',
                     },
                 {
                     'artists': [
                         {
                             'id': 19,
                             'join': ',',
                             'name': 'Sound Associates',
                             },
                         ],
                     'duration': '3:41',
                     'position': '13',
                     'title': 'Boom Box',
                     },
                 {
                     'artists': [
                         {
                             'id': 20,
                             'join': ',',
                             'name': 'Percy X',
                             },
                         ],
                     'duration': '3:39',
                     'position': '14',
                     'title': 'Track 2',
                     },
                 ],
             )
         ''')
     assert actual == expected
def test_documentationtools_GraphvizGraph_01():

    graph = documentationtools.GraphvizGraph()
    graph.node_attributes['shape'] = 'record'

    struct_1 = documentationtools.GraphvizNode()
    struct_1_field_0 = documentationtools.GraphvizField(label='left')
    struct_1.append(struct_1_field_0)
    struct_1_field_1 = documentationtools.GraphvizField(label='middle')
    struct_1.append(struct_1_field_1)
    struct_1_field_2 = documentationtools.GraphvizField(label='right')
    struct_1.append(struct_1_field_2)

    struct_2 = documentationtools.GraphvizNode()
    struct_2_field_0 = documentationtools.GraphvizField(label='one')
    struct_2.append(struct_2_field_0)
    struct_2_field_1 = documentationtools.GraphvizField(label='two')
    struct_2.append(struct_2_field_1)

    struct_3 = documentationtools.GraphvizNode()
    struct_3_field_hello = documentationtools.GraphvizField(
        label='hello')
    struct_3.append(struct_3_field_hello)
    outer_group = documentationtools.GraphvizGroup()
    struct_3.append(outer_group)
    struct_3_field_b = documentationtools.GraphvizField(label='b')
    outer_group.append(struct_3_field_b)
    inner_group = documentationtools.GraphvizGroup()
    outer_group.append(inner_group)
    struct_3_field_c = documentationtools.GraphvizField(label='c')
    inner_group.append(struct_3_field_c)
    struct_3_field_d = documentationtools.GraphvizField(label='d')
    inner_group.append(struct_3_field_d)
    struct_3_field_e = documentationtools.GraphvizField(label='e')
    inner_group.append(struct_3_field_e)
    struct_3_field_f = documentationtools.GraphvizField(label='f')
    outer_group.append(struct_3_field_f)
    struct_3_field_g = documentationtools.GraphvizField(label='g')
    struct_3.append(struct_3_field_g)
    struct_3_field_h = documentationtools.GraphvizField(label='h')
    struct_3.append(struct_3_field_h)

    graph.extend((struct_1, struct_2, struct_3))

    documentationtools.GraphvizEdge().attach(
        struct_1_field_1,
        struct_2_field_0,
        )
    documentationtools.GraphvizEdge().attach(
        struct_1_field_2,
        struct_3_field_d,
        )

    graphviz_format = str(graph)

    assert graphviz_format == stringtools.normalize(
        '''
        digraph G {
            node [shape=record];
            node_0 [label="<f_0> left | <f_1> middle | <f_2> right"];
            node_1 [label="<f_0> one | <f_1> two"];
            node_2 [label="<f_0> hello | { <f_1_0> b | { <f_1_1_0> c | <f_1_1_1> d | <f_1_1_2> e } | <f_1_2> f } | <f_2> g | <f_3> h"];
            node_0:f_1 -> node_1:f_0;
            node_0:f_2 -> node_2:f_1_1_1;
        }
        '''
        )
 def test_01(self):
     iterator = Bootstrapper.get_iterator('artist')
     artist_element = next(iterator)
     artist_element = next(iterator)
     actual = Bootstrapper.prettify(artist_element)
     expected = stringtools.normalize('''
         <?xml version="1.0" ?>
         <artist>
             <id>2</id>
             <name>Mr. James Barth &amp; A.D.</name>
             <realname>Cari Lekebusch &amp; Alexi Delano</realname>
             <profile/>
             <data_quality>Correct</data_quality>
             <namevariations>
                 <name>Mr Barth &amp; A.D.</name>
                 <name>MR JAMES BARTH &amp; A. D.</name>
                 <name>Mr. Barth &amp; A.D.</name>
                 <name>Mr. James Barth &amp; A. D.</name>
             </namevariations>
             <aliases>
                 <name>ADCL</name>
                 <name>Alexi Delano &amp; Cari Lekebusch</name>
                 <name>Crushed Insect &amp; The Sick Puppy</name>
                 <name>Puente Latino</name>
                 <name>Yakari &amp; Delano</name>
             </aliases>
             <members>
                 <id>26</id>
                 <name>Alexi Delano</name>
                 <id>27</id>
                 <name>Cari Lekebusch</name>
             </members>
         </artist>
         ''')
     assert actual.splitlines() == expected.splitlines()
     artist_document = library.Artist.from_element(artist_element)
     actual = format(artist_document)
     expected = stringtools.normalize('''
         discograph.library.mongo.Artist(
             aliases=[
                 discograph.library.mongo.ArtistReference(
                     name='ADCL',
                     ),
                 discograph.library.mongo.ArtistReference(
                     name='Alexi Delano & Cari Lekebusch',
                     ),
                 discograph.library.mongo.ArtistReference(
                     name='Crushed Insect & The Sick Puppy',
                     ),
                 discograph.library.mongo.ArtistReference(
                     name='Puente Latino',
                     ),
                 discograph.library.mongo.ArtistReference(
                     name='Yakari & Delano',
                     ),
                 ],
             discogs_id=2,
             members=[
                 discograph.library.mongo.ArtistReference(
                     discogs_id=26,
                     name='Alexi Delano',
                     ),
                 discograph.library.mongo.ArtistReference(
                     discogs_id=27,
                     name='Cari Lekebusch',
                     ),
                 ],
             name='Mr. James Barth & A.D.',
             name_variations=[
                 'Mr Barth & A.D.',
                 'MR JAMES BARTH & A. D.',
                 'Mr. Barth & A.D.',
                 'Mr. James Barth & A. D.',
                 ],
             real_name='Cari Lekebusch & Alexi Delano',
             )
         ''')
     assert actual == expected
Example #17
0
 def test___call___04(self):
     r'''Missing count takes into account structural roles: members,
     aliases, groups, sublabels, parent labels, etc.
     '''
     artist = discograph.PostgresEntity.get(
         entity_type=1,
         entity_id=1362698,
     )
     roles = ['Alias', 'Member Of']
     grapher = discograph.RelationGrapher(
         artist,
         degree=12,
         roles=roles,
     )
     network = grapher.__call__()
     actual = json.dumps(network, **self.json_kwargs)
     expected = stringtools.normalize('''
         {
             "center": {
                 "key": "artist-1362698",
                 "name": "Revolution (13)"
             },
             "links": [
                 {
                     "key": "artist-144943-alias-artist-535046",
                     "pages": [
                         1
                     ],
                     "role": "Alias",
                     "source": "artist-144943",
                     "target": "artist-535046"
                 },
                 {
                     "key": "artist-144943-member-of-artist-1362698",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-144943",
                     "target": "artist-1362698"
                 },
                 {
                     "key": "artist-271585-member-of-artist-1362698",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-271585",
                     "target": "artist-1362698"
                 }
             ],
             "nodes": [
                 {
                     "cluster": 1,
                     "distance": 1,
                     "id": 144943,
                     "key": "artist-144943",
                     "links": [
                         "artist-144943-alias-artist-535046",
                         "artist-144943-member-of-artist-1362698"
                     ],
                     "missing": 0,
                     "name": "DJ D-Sfase",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 1,
                     "id": 271585,
                     "key": "artist-271585",
                     "links": [
                         "artist-271585-member-of-artist-1362698"
                     ],
                     "missing": 0,
                     "name": "Neuroti-k",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "cluster": 1,
                     "distance": 2,
                     "id": 535046,
                     "key": "artist-535046",
                     "links": [
                         "artist-144943-alias-artist-535046"
                     ],
                     "missing": 0,
                     "name": "Jose Antonio Gonzalez Sanchez",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 0,
                     "id": 1362698,
                     "key": "artist-1362698",
                     "links": [
                         "artist-144943-member-of-artist-1362698",
                         "artist-271585-member-of-artist-1362698"
                     ],
                     "missing": 0,
                     "name": "Revolution (13)",
                     "pages": [
                         1
                     ],
                     "size": 2,
                     "type": "artist"
                 }
             ],
             "pages": 1
         }
     ''')
     assert actual == expected
Example #18
0
 def test___call___03(self):
     artist = discograph.PostgresEntity.get(entity_type=1,
                                            name='Morris Day')
     roles = ['Alias', 'Member Of']
     grapher = discograph.RelationGrapher(
         artist,
         degree=2,
         link_ratio=2,
         roles=roles,
     )
     network = grapher.__call__()
     actual = json.dumps(network, **self.json_kwargs)
     expected = stringtools.normalize('''
         {
             "center": {
                 "key": "artist-152882",
                 "name": "Morris Day"
             },
             "links": [
                 {
                     "key": "artist-100600-member-of-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-100600",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-100600-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-100600",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-113965-member-of-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-113965",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-113965-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-113965",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-152882-member-of-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-152882",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-152882-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-152882",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-23446-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-23446",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-241356-member-of-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-241356",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-241356-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-241356",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-242702-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-242702",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-32550-alias-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Alias",
                     "source": "artist-32550",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-354129-member-of-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-354129",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-354129-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-354129",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-37806-member-of-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-37806",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-37806-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-37806",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-409502-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-409502",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-453969-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-453969",
                     "target": "artist-32550"
                 },
                 {
                     "key": "artist-55449-member-of-artist-2561672",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-55449",
                     "target": "artist-2561672"
                 },
                 {
                     "key": "artist-55449-member-of-artist-32550",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-55449",
                     "target": "artist-32550"
                 }
             ],
             "nodes": [
                 {
                     "distance": 2,
                     "id": 23446,
                     "key": "artist-23446",
                     "links": [
                         "artist-23446-member-of-artist-32550"
                     ],
                     "missing": 1,
                     "name": "Alexander O'Neal",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "cluster": 1,
                     "distance": 1,
                     "id": 32550,
                     "key": "artist-32550",
                     "links": [
                         "artist-100600-member-of-artist-32550",
                         "artist-113965-member-of-artist-32550",
                         "artist-152882-member-of-artist-32550",
                         "artist-23446-member-of-artist-32550",
                         "artist-241356-member-of-artist-32550",
                         "artist-242702-member-of-artist-32550",
                         "artist-32550-alias-artist-2561672",
                         "artist-354129-member-of-artist-32550",
                         "artist-37806-member-of-artist-32550",
                         "artist-409502-member-of-artist-32550",
                         "artist-453969-member-of-artist-32550",
                         "artist-55449-member-of-artist-32550"
                     ],
                     "missing": 0,
                     "name": "The Time",
                     "pages": [
                         1
                     ],
                     "size": 11,
                     "type": "artist"
                 },
                 {
                     "distance": 2,
                     "id": 37806,
                     "key": "artist-37806",
                     "links": [
                         "artist-37806-member-of-artist-2561672",
                         "artist-37806-member-of-artist-32550"
                     ],
                     "missing": 2,
                     "name": "Jesse Johnson",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 2,
                     "id": 55449,
                     "key": "artist-55449",
                     "links": [
                         "artist-55449-member-of-artist-2561672",
                         "artist-55449-member-of-artist-32550"
                     ],
                     "missing": 3,
                     "name": "Terry Lewis",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 2,
                     "id": 100600,
                     "key": "artist-100600",
                     "links": [
                         "artist-100600-member-of-artist-2561672",
                         "artist-100600-member-of-artist-32550"
                     ],
                     "missing": 1,
                     "name": "Monte Moir",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 2,
                     "id": 113965,
                     "key": "artist-113965",
                     "links": [
                         "artist-113965-member-of-artist-2561672",
                         "artist-113965-member-of-artist-32550"
                     ],
                     "missing": 4,
                     "name": "Jellybean Johnson",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 0,
                     "id": 152882,
                     "key": "artist-152882",
                     "links": [
                         "artist-152882-member-of-artist-2561672",
                         "artist-152882-member-of-artist-32550"
                     ],
                     "missing": 0,
                     "name": "Morris Day",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "cluster": 2,
                     "distance": 2,
                     "id": 241356,
                     "key": "artist-241356",
                     "links": [
                         "artist-241356-member-of-artist-2561672",
                         "artist-241356-member-of-artist-32550"
                     ],
                     "missing": 4,
                     "name": "James Harris III",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "cluster": 3,
                     "distance": 2,
                     "id": 242702,
                     "key": "artist-242702",
                     "links": [
                         "artist-242702-member-of-artist-32550"
                     ],
                     "missing": 5,
                     "name": "Paul Peterson",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 2,
                     "id": 354129,
                     "key": "artist-354129",
                     "links": [
                         "artist-354129-member-of-artist-2561672",
                         "artist-354129-member-of-artist-32550"
                     ],
                     "missing": 1,
                     "name": "Jerome Benton",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 2,
                     "id": 409502,
                     "key": "artist-409502",
                     "links": [
                         "artist-409502-member-of-artist-32550"
                     ],
                     "missing": 1,
                     "name": "Mark Cardenas",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 2,
                     "id": 453969,
                     "key": "artist-453969",
                     "links": [
                         "artist-453969-member-of-artist-32550"
                     ],
                     "missing": 2,
                     "name": "Jerry Hubbard",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "cluster": 1,
                     "distance": 1,
                     "id": 2561672,
                     "key": "artist-2561672",
                     "links": [
                         "artist-100600-member-of-artist-2561672",
                         "artist-113965-member-of-artist-2561672",
                         "artist-152882-member-of-artist-2561672",
                         "artist-241356-member-of-artist-2561672",
                         "artist-32550-alias-artist-2561672",
                         "artist-354129-member-of-artist-2561672",
                         "artist-37806-member-of-artist-2561672",
                         "artist-55449-member-of-artist-2561672"
                     ],
                     "missing": 0,
                     "name": "The Original 7ven",
                     "pages": [
                         1
                     ],
                     "size": 7,
                     "type": "artist"
                 }
             ],
             "pages": 1
         }
     ''')
     assert actual == expected
 def test___call___04(self):
     r'''Missing count takes into account structural roles: members,
     aliases, groups, sublabels, parent labels, etc.
     '''
     artist = discograph.PostgresEntity.get(
         entity_type=1, 
         entity_id=1362698,
         )
     roles = ['Alias', 'Member Of']
     grapher = discograph.RelationGrapher(
         artist,
         degree=12,
         roles=roles,
         )
     network = grapher.__call__()
     actual = json.dumps(network, **self.json_kwargs)
     expected = stringtools.normalize('''
         {
             "center": {
                 "key": "artist-1362698",
                 "name": "Revolution (13)"
             },
             "links": [
                 {
                     "key": "artist-144943-alias-artist-535046",
                     "pages": [
                         1
                     ],
                     "role": "Alias",
                     "source": "artist-144943",
                     "target": "artist-535046"
                 },
                 {
                     "key": "artist-144943-member-of-artist-1362698",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-144943",
                     "target": "artist-1362698"
                 },
                 {
                     "key": "artist-271585-member-of-artist-1362698",
                     "pages": [
                         1
                     ],
                     "role": "Member Of",
                     "source": "artist-271585",
                     "target": "artist-1362698"
                 }
             ],
             "nodes": [
                 {
                     "cluster": 1,
                     "distance": 1,
                     "id": 144943,
                     "key": "artist-144943",
                     "links": [
                         "artist-144943-alias-artist-535046",
                         "artist-144943-member-of-artist-1362698"
                     ],
                     "missing": 0,
                     "name": "DJ D-Sfase",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 1,
                     "id": 271585,
                     "key": "artist-271585",
                     "links": [
                         "artist-271585-member-of-artist-1362698"
                     ],
                     "missing": 0,
                     "name": "Neuroti-k",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "cluster": 1,
                     "distance": 2,
                     "id": 535046,
                     "key": "artist-535046",
                     "links": [
                         "artist-144943-alias-artist-535046"
                     ],
                     "missing": 0,
                     "name": "Jose Antonio Gonzalez Sanchez",
                     "pages": [
                         1
                     ],
                     "size": 0,
                     "type": "artist"
                 },
                 {
                     "distance": 0,
                     "id": 1362698,
                     "key": "artist-1362698",
                     "links": [
                         "artist-144943-member-of-artist-1362698",
                         "artist-271585-member-of-artist-1362698"
                     ],
                     "missing": 0,
                     "name": "Revolution (13)",
                     "pages": [
                         1
                     ],
                     "size": 2,
                     "type": "artist"
                 }
             ],
             "pages": 1
         }
     ''')
     assert actual == expected
def test_documentationtools_GraphvizGraph_01():

    graph = documentationtools.GraphvizGraph()
    graph.node_attributes['shape'] = 'record'

    struct_1 = documentationtools.GraphvizNode()
    struct_1_field_0 = documentationtools.GraphvizField(label='left')
    struct_1.append(struct_1_field_0)
    struct_1_field_1 = documentationtools.GraphvizField(label='middle')
    struct_1.append(struct_1_field_1)
    struct_1_field_2 = documentationtools.GraphvizField(label='right')
    struct_1.append(struct_1_field_2)

    struct_2 = documentationtools.GraphvizNode()
    struct_2_field_0 = documentationtools.GraphvizField(label='one')
    struct_2.append(struct_2_field_0)
    struct_2_field_1 = documentationtools.GraphvizField(label='two')
    struct_2.append(struct_2_field_1)

    struct_3 = documentationtools.GraphvizNode()
    struct_3_field_hello = documentationtools.GraphvizField(label='hello')
    struct_3.append(struct_3_field_hello)
    outer_group = documentationtools.GraphvizGroup()
    struct_3.append(outer_group)
    struct_3_field_b = documentationtools.GraphvizField(label='b')
    outer_group.append(struct_3_field_b)
    inner_group = documentationtools.GraphvizGroup()
    outer_group.append(inner_group)
    struct_3_field_c = documentationtools.GraphvizField(label='c')
    inner_group.append(struct_3_field_c)
    struct_3_field_d = documentationtools.GraphvizField(label='d')
    inner_group.append(struct_3_field_d)
    struct_3_field_e = documentationtools.GraphvizField(label='e')
    inner_group.append(struct_3_field_e)
    struct_3_field_f = documentationtools.GraphvizField(label='f')
    outer_group.append(struct_3_field_f)
    struct_3_field_g = documentationtools.GraphvizField(label='g')
    struct_3.append(struct_3_field_g)
    struct_3_field_h = documentationtools.GraphvizField(label='h')
    struct_3.append(struct_3_field_h)

    graph.extend((struct_1, struct_2, struct_3))

    documentationtools.GraphvizEdge().attach(
        struct_1_field_1,
        struct_2_field_0,
    )
    documentationtools.GraphvizEdge().attach(
        struct_1_field_2,
        struct_3_field_d,
    )

    graphviz_format = str(graph)

    assert graphviz_format == stringtools.normalize('''
        digraph G {
            node [shape=record];
            node_0 [label="<f_0> left | <f_1> middle | <f_2> right"];
            node_1 [label="<f_0> one | <f_1> two"];
            node_2 [label="<f_0> hello | { <f_1_0> b | { <f_1_1_0> c | <f_1_1_1> d | <f_1_1_2> e } | <f_1_2> f } | <f_2> g | <f_3> h"];
            node_0:f_1 -> node_1:f_0;
            node_0:f_2 -> node_2:f_1_1_1;
        }
        ''')